package com.neuedu.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neuedu.projos.Cate;
import com.neuedu.projos.ProductPage;
import com.neuedu.service.CateServ;
import com.neuedu.service.CateServImpl;

/**
 * Servlet implementation class CateController
 */
@WebServlet("/CateController")
public class CateController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CateController() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String pagNum =request.getParameter("pageNum");
		int pgN =Integer.parseInt(pagNum);
		CateServ cs = new CateServImpl();
		ProductPage <Cate> cates = cs.getsCate(pgN, 3);
		request.setAttribute("cates", cates);
		request.getRequestDispatcher("WEB-INF/page/cates.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
